<template>
    <div class="check_list" v-if="checkListData.length">
            <van-collapse v-model="activeNames" accordion v-for="(item,index) in checkListData" :key="index">
                <van-collapse-item :name="index" :class="{show_right_arrow:item.template}">
                    <div slot="title">
                        <div class="check_list_title" v-if="item.template">
                            <span>{{item.template.name}}</span>
                            <div class="arrow_go">
                                <span @click="goAppraisalIndexDescription(item.template_id)">考核指标说明</span>
                                <van-icon name="arrow" />
                            </div>
                        </div>
                        <p class="collapse_item_title">
                            <span class="start_end">{{item.begin_date}}至{{item.end_date}}</span>
                            <span v-if="item.appraisal_status==2" class="status">进行中</span>
                            <span :class="{scores:item.pass==0}">{{item.score}}分</span>
                        </p>
                    </div>
                    <ul class="check_list_content">
                        <li v-for="(collapseList,i) in item.targets" :key="i">
                            <p class="check_list_decs"><span class="index_tag">{{i+1}}</span>{{collapseList.target_name}}</p>
                            <div class="check_list_progress">
                                <span>{{collapseList.target_value}}</span>
                                <van-progress :percentage="Number(collapseList.target_score)" color="linear-gradient(to right, #ffa802, #fe6601)" :show-pivot="false" />
                                <span :class="{scores:Number(collapseList.target_score)<Number(collapseList.target_value)}">{{collapseList.target_score}}分</span>
                            </div>
                        </li>
                    </ul>
                </van-collapse-item>
            </van-collapse>
    </div>
</template>
<script>
export default {
    data() {
        return {
            activeNames: 0,
            loading: false,
            finished: false,
            page:1,
            limit:10,
            staffer_id:''
        }
    },
    props:{
        checkListData:{
            type:Array,
            default:()=>[]
        }
    },
    created(){
        if (this.$route.name == "performanceTabs") {
            this.staffer_id = localStorage.getItem('staffer_id');
        } else {
            this.staffer_id = this.$route.query.id;
        }
    },
    methods:{
        goAppraisalIndexDescription(id){
            this.$router.push({name:'appraisalIndexDescription',query:{id:id}})
        },
        // onLoad(){
        //     // 异步更新数据
        //     checkList({token:this.$store.state.token,staffer_id:this.staffer_id,page:this.page,per_page:this.limit}).then(res=>{
        //         let data = res.data;
        //         // 加载状态结束
        //         this.loading = false;
        //         // 数据全部加载完成
        //         if (data.performances.length < 10) {
        //             this.finished = true;
        //         }
        //         this.page += 1;
        //         this.checkListData.push(...data.performances);
        //     }).catch(err=>{
        //         console.log(err)
        //     });
        // }
    }
}
</script>
<style lang="less" scoped>
.check_list{
    width: 100%;
    height: 100%;
    background: #fff;
    border-radius: 10px;
    margin-top: 15px;
    padding: 10px 15px;
    box-sizing: border-box;
    .check_list_title{
        width: 100%;
        height: 30px;
        line-height: 30px;
        background: none;
        font-weight: 500;
        font-size: 15px;
        color: #232428;
        box-sizing: border-box;
        border-bottom: 1px solid #f7f7f7;
        display: flex;
        justify-content: space-between;
        .arrow_go{
            width: 100px;
            // display: flex;
            // justify-content: space-between;
            font-size: 13px;
            color: #676767;
            text-align: right;
            cursor: pointer;
            span{vertical-align: top;}
            i{
                line-height: 30px;
                font-weight: bold;
                font-size: 15px;
                color: #9a9a9a;
            }
        }
    }
    .status{
        padding: 3px 6px;
        border-radius: 5px;
        border: 1px solid #fe661a;
        color: #fe661a;
        display: inline;
        box-sizing: border-box;
        line-height: 20px;
    }
    .check_list_content{
        width: 100%;
        height: auto;
        box-sizing: border-box;
        li{
            width: 100%;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 2px solid #f7f7f7;
            .check_list_decs{
                flex: 6;
                overflow:hidden;
                white-wrap:nowrap;
                text-overflow:ellipsis;
                .index_tag{
                    color: #fff;
                    background: #ffbb00;
                    display: inline-block;
                    width: 20px;
                    height: 20px;
                    line-height: 20px;
                    text-align: center;
                    border-radius: 20px;
                    margin-right: 5px;
                }
            }
            .check_list_progress{text-align: right;flex: 2;font-size: 11px;}
            .check_list_progress .van-progress{margin: 5px 0;}
        }
        li:last-child{border-bottom: none;}
    }
}

/deep/.van-icon{font-size: 13px;line-height: 50px;}
/deep/.van-collapse-item__content{
    padding: 0;
    font-size: 13px;
}
/deep/ .van-collapse{margin-top: 0;border-bottom: 1px solid #f7f7f7;}
/deep/.van-cell{
    font-size: 12px;
    padding: 0 !important;
    box-sizing: border-box;
    line-height: 50px;
    color: #232426;
    background-color: #fff;
}
/deep/ .van-collapse .show_right_arrow .van-icon{display: none;}
/deep/ .van-collapse .show_right_arrow .check_list_title .van-icon{display: inline-block;}
/deep/ .van-collapse:last-child{border-bottom: none;}
/deep/.van-cell:last-child{border-bottom: none;}
.collapse_item_title{
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.scores{color: #ff3f66;}


</style>
